﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;
using FlexPlatform.GeneralUse;
using FlexPlatform.Shared.Validation;
using System.Collections.ObjectModel;

namespace FlexPlatform.Common.Configuration
{
    public class PropertyValidationConfiguration<T> : IPropertyValidationConfiguration
    {
        private Expression<Func<T, object>> clsProperty;
        private Collection<IValidationRule> clsValidationRules;

        public PropertyValidationConfiguration(Expression<Func<T, object>> propertyPath)
        {
            clsProperty = propertyPath;
            clsValidationRules = new Collection<IValidationRule>();
        }

        public string PropertyName
        {
            get
            {
                return ReflectionHelper.GetPropertyName(clsProperty);
            }
        }


        public IEnumerable<IValidationRule> ValidationRules
        {
            get { return clsValidationRules; }
        }
    }
}
